//
//  HomeViewController.m
//  QuickCure
//
//  Created by haoge on 16/9/10.
//  Copyright © 2016年 haoge. All rights reserved.
//
#import "BZPublicVC.h"
#import "HomeViewController.h"
#import "DVWeatherView.h"
#import "DVLocationTableViewController.h"
#import "DVPicplayerView.h"
#import "DVSicknessItemsView.h"
#import "BZPublicVC.h"

#import "BZCureOneVC.h"

@interface HomeViewController ()<UICollectionViewDelegate>
@property(nonatomic,weak)DVWeatherView* weatherView;
@property(nonatomic,weak)DVSicknessItemsView * sicknessItemsView;
@end

@implementation HomeViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    [self setupUI];
    
    [self initializeForView];
    
}

- (void)setupUI {
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.navigationController.navigationBar.barTintColor = kThemeColor;
    
    self.title = @"白大夫";

    self.navigationController.navigationBar.translucent = NO;
    
    self.navigationItem.leftBarButtonItem.image  =  [self.navigationItem.leftBarButtonItem.image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    
    
}


-(void)initializeForView{
    
    DVWeatherView* weatherView = [[DVWeatherView alloc]initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT/8)];
    
    [self.view addSubview:weatherView];
    
    self.weatherView = weatherView;
    
    [weatherView.locationBT addTarget:self action:@selector(justTolocationView) forControlEvents:UIControlEventTouchUpInside];
    
    
    DVPicplayerView*  picplayerView = [[DVPicplayerView alloc]initWithFrame:CGRectMake(0, CGRectGetMaxY(weatherView.frame), SCREEN_WIDTH, SCREEN_HEIGHT/3.5)];
    
    [self.view addSubview:picplayerView];
    
    
    
    
    
    DVSicknessItemsView* sicknessItemsView = [[DVSicknessItemsView alloc]init];
    
    [self.view addSubview:sicknessItemsView];
    
    
    [sicknessItemsView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        
        make.top.equalTo(picplayerView.mas_bottom);
        
        make.left.right.bottom.equalTo(self.view);


    }];
    
    self.sicknessItemsView = sicknessItemsView;
    
    self.sicknessItemsView.collectionView.delegate = self;



    
}




-(void)reloadWeatherViewData:(NSString*)cityName{
    
    
    if (cityName.length) {
        
        self.weatherView.cityName = cityName;
        
    }
    
    
}


-(void)justTolocationView{
    
    
    [self.navigationController pushViewController:[DVLocationTableViewController new] animated:YES];
    
    
    
}


- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 5) {
        
        BZPublicVC* publicVCn =  [[BZPublicVC alloc]init];
        
        [self.navigationController pushViewController:publicVCn animated:YES];
        
        return;
        
    }
    
    BZCureOneVC* cureOneVC  =  [[BZCureOneVC alloc]init];
    
    cureOneVC.illName = self.sicknessItemsView.labelStrArr[indexPath.row];
    cureOneVC.ci1_id = @(indexPath.row+1);
    
    
    [self.navigationController pushViewController:cureOneVC animated:YES];
    
    
    
    
}


@end






















